<template>
  <div class="warehouse-layout">
    <el-container class="main-container">
      <!-- 顶部导航栏 -->
      <el-header class="header">
        <div class="header-left">
          <el-icon class="menu-icon" @click="toggleSidebar">
            <Menu />
          </el-icon>
          <h1 class="system-title">仓储管理系统</h1>
        </div>
        <div class="header-right">
          <el-input
            v-model="searchKeyword"
            placeholder="输入搜索关键词"
            class="search-input"
            size="small"
          >
            <template #prefix>
              <el-icon><Search /></el-icon>
            </template>
          </el-input>
          <el-badge :value="3" class="message-badge">
            <el-icon class="message-icon"><Bell /></el-icon>
          </el-badge>
          <el-link type="primary" class="header-link">项目介绍</el-link>
          <el-link type="primary" class="header-link">作品首页</el-link>
          <el-avatar :size="32" class="user-avatar">
            <el-icon><User /></el-icon>
          </el-avatar>
          <el-dropdown>
            <span class="user-dropdown">
              admin <el-icon><ArrowDown /></el-icon>
            </span>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item>个人设置</el-dropdown-item>
                <el-dropdown-item>退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </el-header>

      <el-container class="content-container">
        <!-- 侧边栏 -->
        <el-aside :width="sidebarWidth" class="sidebar">
          <el-menu
            :default-active="activeMenu"
            class="sidebar-menu"
            :collapse="isCollapse"
            background-color="#f8f9fa"
            text-color="#333"
            active-text-color="#409eff"
            router
          >
            <!-- 货品管理 -->
            <el-sub-menu index="goods">
              <template #title>
                <el-icon><Goods /></el-icon>
                <span>货品管理</span>
              </template>
              <el-menu-item index="goods-info">
                <el-icon><Document /></el-icon>
                <span>货品信息</span>
              </el-menu-item>
              <el-menu-item index="goods-type">
                <el-icon><Collection /></el-icon>
                <span>货品类型</span>
              </el-menu-item>
            </el-sub-menu>

            <!-- 出入库管理 -->
            <el-sub-menu index="inventory">
              <template #title>
                <el-icon><Box /></el-icon>
                <span>出入库管理</span>
              </template>
              <el-menu-item index="inbound">
                <el-icon><Plus /></el-icon>
                <span>入库管理</span>
              </el-menu-item>
              <el-menu-item index="outbound">
                <el-icon><Minus /></el-icon>
                <span>出库管理</span>
              </el-menu-item>
              <el-menu-item index="inventory" class="active-menu-item">
                <el-icon><Check /></el-icon>
                <span>库存盘点</span>
              </el-menu-item>
              <el-menu-item index="dify">
                <el-icon><Switch /></el-icon>
                <span>Dify</span>
              </el-menu-item>
            </el-sub-menu>

           
          </el-menu>
        </el-aside>

        <!-- 主内容区域 -->
        <el-main>
          <div style="width: 1400px;">
            <RouterView />
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from 'vue'
import { useRouter } from 'vue-router'
import {
  Menu,
  Search,
  Bell,
  User,
  ArrowDown,
  Goods,
  Document,
  Collection,
  Box,
  Plus,
  Minus,
  Check,
  Switch,
  List,
  ShoppingCart,
  RefreshLeft,
  Sell,
  RefreshRight,
  TrendCharts,
  PieChart,
  UserFilled,
  Shop,
  Avatar
} from '@element-plus/icons-vue'

const router = useRouter()
const searchKeyword = ref('')
const isCollapse = ref(false)
const activeMenu = ref('inventory-check')

const sidebarWidth = computed(() => isCollapse.value ? '64px' : '220px')

const toggleSidebar = () => {
  isCollapse.value = !isCollapse.value
}




</script>

<style scoped>
.warehouse-layout {
  height: 100vh;
  width: 180vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.main-container {
  height: 100vh;
  background: #f5f7fa;
}

.header {
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  height: 60px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.menu-icon {
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.menu-icon:hover {
  transform: scale(1.1);
}

.system-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  background: linear-gradient(45deg, #fff, #e8f4fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.search-input {
  width: 200px;
}

.search-input :deep(.el-input__wrapper) {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 20px;
}

.message-badge {
  margin: 0 10px;
}

.message-icon {
  font-size: 18px;
  color: white;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.message-icon:hover {
  transform: scale(1.1);
}

.header-link {
  color: white;
  text-decoration: none;
  font-size: 14px;
}

.header-link:hover {
  color: #e8f4fd;
}

.user-avatar {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.user-dropdown {
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
}

.content-container {
  height: calc(100vh - 60px);
}

.sidebar {
  background: #f8f9fa;
  border-right: 1px solid #e4e7ed;
  transition: width 0.3s ease;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.sidebar-menu {
  border: none;
  height: 100%;
}

.sidebar-menu :deep(.el-menu-item) {
  height: 50px;
  line-height: 50px;
  margin: 2px 8px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.sidebar-menu :deep(.el-menu-item:hover) {
  background: linear-gradient(90deg, #409eff 0%, #67c23a 100%);
  color: white;
  transform: translateX(5px);
}

.sidebar-menu :deep(.el-menu-item.is-active) {
  background: linear-gradient(90deg, #409eff 0%, #67c23a 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
}

.sidebar-menu :deep(.el-sub-menu__title) {
  height: 50px;
  line-height: 50px;
  margin: 2px 8px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.sidebar-menu :deep(.el-sub-menu__title:hover) {
  background: linear-gradient(90deg, #409eff 0%, #67c23a 100%);
  color: white;
}

.active-menu-item {
  background: linear-gradient(90deg, #67c23a 0%, #409eff 100%) !important;
  color: white !important;
  box-shadow: 0 4px 12px rgba(103, 194, 58, 0.3) !important;
}

.main-content {
  background: #f5f7fa;
  padding: 20px;
  overflow-y: auto;
}

.content-wrapper {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  min-height: calc(100vh - 120px);
  padding: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .header-right {
    gap: 10px;
  }
  
  .search-input {
    width: 150px;
  }
  
  .system-title {
    font-size: 16px;
  }
}

/* 动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.content-wrapper {
  animation: fadeIn 0.5s ease-out;
}
</style>
